package 结构型模式.享元模式.饿汉式俄罗斯方块;

import java.util.HashMap;

public class BoxFactory {
    private HashMap<String,AbstractBox> map;

    //在构造方法中进行初始化操作
    public BoxFactory() {
        map=new HashMap<String,AbstractBox>();
        map.put("I",new IBox());
        map.put("O",new OBox());
        map.put("L",new LBox());
    }
    //提供一个方法获取该工厂类对象
    private static BoxFactory factory=new BoxFactory();
    public static BoxFactory getInstance(){
        return factory;
    }

    //根据名称获取图形对象
    public AbstractBox getShape(String shape){
        return map.get(shape);
    }
}
